/*
 * Copyright 2013 Mounir IDRASSI  (mounir.idrassi@idrix.fr, for IDRIX)
 *
 * This file is part of SimCardManager.
 *
 * SimCardManager is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * SimCardManager is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with SimCardManager.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

// PhoneBookDlg.h : interface of the CPhoneBookDlg class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

#include "PcscManager.h"

class CPhoneBookDlg : public CDialogImpl<CPhoneBookDlg>
{
public:
   enum { IDD = IDD_PHONE_BOOK };
   typedef enum { ADN_DLG, FDN_DLG, SMS_DLG} TYPE;
   CSimPhoneBook* m_phoneBook;
   CSimSMSList* m_smsList;
   CListViewCtrl m_list;
   TYPE m_type;
   bool m_bAscending;
   int m_iColumn;
   int m_count;

   CPhoneBookDlg(CSimPhoneBook& phoneBook, TYPE type) : CDialogImpl<CPhoneBookDlg>(), m_phoneBook(&phoneBook), m_smsList(NULL), m_type(type)
   {
      m_bAscending = true;
   }

   CPhoneBookDlg(CSimSMSList& smsList) : CDialogImpl<CPhoneBookDlg>(), m_phoneBook(NULL), m_smsList(&smsList), m_type(SMS_DLG)
   {
      m_bAscending = true;
   }

   BEGIN_MSG_MAP(CPhoneBookDlg)
      MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
      COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
      COMMAND_HANDLER(IDC_EXPORT, BN_CLICKED, OnBnClickedExport)
      MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
   END_MSG_MAP()


   // Handler prototypes (uncomment arguments if needed):
   //	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
   //	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
   //	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

   LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);

   LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
   {
      EndDialog(wID);
      return 0;
   }
   LRESULT OnBnClickedExport(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

   static int CALLBACK LVCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);

   LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
};
